<?php
	$filterVarName = $this->getGridBlock()->getVarNameFilter();
	$show = $this->getGridBlock()->getParam($filterVarName, false) ? true : false;
	$session = Mage::getSingleton('adminhtml/session');
?>
<script type="text/javascript">
	function askForSave()
	{
		var name = prompt("Please add the Name for the filter you want to save.",'My Filter');
		if (!name) {
			return false;
		} else {
			new Ajax.Request('<?php echo $this->getSaveUrl(); ?>' , {
					parameters: {
									name: name,
									filterKey : '<?php echo $filterVarName?>',
									filterValue : <?php echo $this->getGridBlock()->getJsObjectName() ?> .url
								},
			  		onSuccess: function(transport) {
			  			var jsonResponse=transport.responseText.evalJSON();
			  			if (jsonResponse.error == '1') {
			  				$('messages').innerHTML = '<ul class="messages"><li class="error-msg"><ul><li>' + jsonResponse.msg + '</li></ul></li></ul>';
			  			} else {
			  				$('messages').innerHTML = '<ul class="messages"><li class="success-msg"><ul><li>' + jsonResponse.msg + '</li></ul></li></ul>';
				  		}
					}
			});
		}
	}

	<?php if (!$show) :?>
		$('myfilter_button').disabled = true;
		$('myfilter_button').addClassName('disabled');
	<?php endif;?>
</script>